]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
texture-cache: Warn when loading sliced image fails
authorFlorian Müllner <fmuellner@gnome.org>
Tue, 22 Nov 2016 17:12:35 +0000 (18:12 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Tue, 22 Nov 2016 17:38:10 +0000 (18:38 +0100)
Sliced images are loaded into a group actor with one child actor
per slice. In case loading the image fails, we currently quietly
return the empty group actor, which makes diagnosing problems
unnecessarily hard - just be a bit more verbose on failure.

https://bugzilla.gnome.org/show_bug.cgi?id=774805

src/st/st-texture-cache.c

index 1c718acb9be584a2fe75ae7c7904b8e4f9a0c501..281241ade9f532c9db516a097648a8e481c1d7de 100644 (file)
@@ -1088,6 +1088,7 @@ load_sliced_image (GTask        *result,
   GdkPixbuf *pix;
   gint width, height, y, x;
   GdkPixbufLoader *loader;
+  GError *error = NULL;
   gchar *buffer = NULL;
   gsize length;
 
@@ -1099,11 +1100,17 @@ load_sliced_image (GTask        *result,
   loader = gdk_pixbuf_loader_new ();
   g_signal_connect (loader, "size-prepared", G_CALLBACK (on_loader_size_prepared), data);
 
-  if (!g_file_load_contents (data->gfile, NULL, &buffer, &length, NULL, NULL))
-    goto out;
+  if (!g_file_load_contents (data->gfile, NULL, &buffer, &length, NULL, &error))
+    {
+      g_warning ("Failed to open sliced image: %s", error->message);
+      goto out;
+    }
 
-  if (!gdk_pixbuf_loader_write (loader, (const guchar *) buffer, length, NULL))
-    goto out;
+  if (!gdk_pixbuf_loader_write (loader, (const guchar *) buffer, length, &error))
+    {
+      g_warning ("Failed to load image: %s", error->message);
+      goto out;
+    }
 
   if (!gdk_pixbuf_loader_close (loader, NULL))
     goto out;
@@ -1128,6 +1135,7 @@ load_sliced_image (GTask        *result,
    * though the subpixbufs will hold a reference. */
   g_object_unref (loader);
   g_free (buffer);
+  g_clear_pointer (&error, g_error_free);
   g_task_return_pointer (result, res, free_glist_unref_gobjects);
 }